package controller

import (
	"context"
	"lot_admin_api/api"
	"lot_admin_api/internal/model"
	"lot_admin_api/internal/service"
)

var Dictionary = cDictionary{}

type cDictionary struct{}

// AddDictionary  新增数据字典
func (h *cDictionary) AddDictionary(ctx context.Context, req *api.AddDictionaryReq) (res *model.DictionaryIdRes, err error) {
	id, _ := service.Dictionary().AddDictionary(ctx, req.DictionaryInfo)
	res = &model.DictionaryIdRes{
		Id: id,
	}
	return res, err
}

// UpdateDictionary  编辑数据字典
func (h *cDictionary) UpdateDictionary(ctx context.Context, req *api.UpdateDictionaryReq) (res *model.DictionaryIdRes, err error) {
	id, _ := service.Dictionary().UpdateDictionary(ctx, req)
	res = &model.DictionaryIdRes{
		Id: id,
	}
	return res, err
}

// DeleteDictionary  删除数据字典
func (h *cDictionary) DeleteDictionary(ctx context.Context, req *api.DeleteDictionaryReq) (res *model.DictionaryIdRes, err error) {
	id, _ := service.Dictionary().DeleteDictionary(ctx, req)
	res = &model.DictionaryIdRes{
		Id: id,
	}
	return res, err
}

// SearchDictionaryList  获取数据字典数组
func (h *cDictionary) SearchDictionaryList(ctx context.Context, req *api.SearchDictionaryListReq) (res *model.DictionaryListRes, err error) {
	res, err = service.Dictionary().SearchDictionaryList(ctx, req.SearchDictionaryListReq)
	return res, err
}

// SearchDictionaryOne  通过id获取数据字典
func (h *cDictionary) SearchDictionaryOne(ctx context.Context, req *api.SearchDictionaryOneReq) (res *model.DictionaryInfoRes, err error) {
	res, err = service.Dictionary().SearchDictionaryOne(ctx, req)
	return res, err
}
